<template>
  <div class="home">
    home
    <button @click="add">改变state的num</button>
    <p>{{ this.$store.state.num }}</p>
    <p>{{ storeNum }}</p>
    <p>
      <router-link to="/city"
        ><button>{{ this.$store.state.city }}</button></router-link
      >
    </p>
  </div>
</template>

<script>
export default {
  name: "Home",
  data() {
    return {
      count: 1,
    };
  },
  methods: {
    add() {
      this.$store.dispatch("addNum");
    },
  },
  computed: {
    storeNum() {
      return this.$store.state.num;
    },
  },
  beforeRouteEnter (to) {
    // 权限的判断
    console.log(to);
  }
  // beforeCreate(){
  //   console.log("beforeCreate")
  // },
  // created(){
  //   console.log("created")
  // },
  // beforeMount(){
  //   console.log("beforeMount")
  // },
  // mounted(){
  //   console.log("mounted")
  // },
  // beforeDestroy(){
  //   console.log("beforeDestroy")
  // },
  // destroyed(){
  //   console.log("destroyed")
  // },
  // activated(){
  //   console.log("activated")
  // },
  // deactivated(){
  //   console.log("deactivated")
  // }
};
</script>
